package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	SellerEventNew           = "erp.SellerNew"
	SellerEventBeforeCreate  = "erp.SellerBeforeCreate"
	SellerEventBeforeUpdate  = "erp.SellerBeforeUpdate"
	SellerEventBeforeSave    = "erp.SellerBeforeCreate erp.SellerBeforeUpdate"
	SellerEventAfterCreate   = "erp.SellerAfterCreate"
	SellerEventAfterUpdate   = "erp.SellerAfterUpdate"
	SellerEventAfterSave     = "erp.SellerAfterCreate erp.SellerAfterUpdate"
	SellerEventDelete        = "erp.SellerDelete"
	SellerAccessControlEvent = "erp.SellerAccessControl"
)

func GetSellerConfig() *mgo.DocConfig {
	return Seller_Config
}

var Seller_Config *mgo.DocConfig

func init() {
	Seller_Config = NewSellerConfig()
}
func NewSellerConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.Seller",
		Fields: []string{
			"name", "fastName", "cat", "level", "isOn",
		},
		RelationFields: []string{
			"cat", "level",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"cat": {
				Config:     GetSellerCategoryConfig,
				DocName:    "SellerCategory",
				JoinType:   "O",
				KeyInside:  "catId",
				KeyOutSide: "id",
			},
			"level": {
				Config:     GetSellerLevelConfig,
				DocName:    "SellerLevel",
				JoinType:   "O",
				KeyInside:  "levelId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
